function normalizedM = swnormal(M)
% Normalize (sparse matrix)
% scripted by Sun Sibai
% 2015 Apr. 8
%   M_{jk} = M_{jk} / max(M_{::})
  [id1,id2,val] = find(M); % retrieve all nonzero elements of sparse matrix M
  maxM = max(val);
  val = val./maxM;
  normalizedM = sparse(id1,id2,val);
end
